package com.zyp.tool;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;

/**
 * 工具类
 */
public class Tool {
    //获取到前端传过来的值进行转换字符
    public static String CharacterConversion(String strings) throws UnsupportedEncodingException {
        return new String(strings.getBytes("ISO-8859-1"), "utf-8");
    }

    //获取到从前端传过来的值
    public static Object[] GetValue(HttpServletRequest request) {
        String[] add = new String[9];
        int i = 0;
        Enumeration<String> adds = request.getParameterNames();
        System.out.println(adds);
        while (adds.hasMoreElements()) {
            String paramName = adds.nextElement();
            add[i] = request.getParameter(paramName);
            i++;
        }
        //将值存入
        Object s = add[3] + "-" + add[4] + "-" + add[5];
        if (add[3].equals("") || add[4].equals("") || add[5].equals("")) {
            s = "";
        }
        Object[] o = {null, add[0], add[1], add[2], s, add[6], add[7]};
        for (Object o1 : o) {
            System.out.println(o1);
        }
        return o;
    }
}
